package com.mingle.iwalk;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

public class IndicateLayout extends LinearLayout {

	public View mIcon;
	public ProgressBar mProgressBar;
	public TextView mInfo;
	
	public IndicateLayout(Context context) {
		this(context, null);
		
	}

	public IndicateLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
		
		LayoutInflater inflater = LayoutInflater.from(context);

	    View view = inflater.inflate(R.layout.indicate_layout, this);
	    mIcon = view.findViewById(R.id.icon);
	    mProgressBar = (ProgressBar) view.findViewById(R.id.progress_bar);
	    mInfo = (TextView) view.findViewById(R.id.info); 
	    
	    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.IWalkWidget, 0, 0);
	    Drawable bg = a.getDrawable(R.styleable.IWalkWidget_background);
	    String lab = a.getString(R.styleable.IWalkWidget_text);
	    a.recycle();
	    
	    if(bg != null)
	    {
	    	mIcon.setBackgroundDrawable(bg);
	    }
	    
	    if(lab!=null && lab.length()!=0)
	    {
	    	mInfo.setText(lab);
	    }
	}

}
